convert non-compact trie to a compact trie